﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Imaging;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Collections.Specialized;
using System.Xml.Linq;

namespace Silent.Utilities
{
    public static class Screenshooter
    {
        private static readonly Rectangle m_screenBounds;

        static Screenshooter()
        {
            m_screenBounds = new Rectangle(0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
        }

        public static Rectangle ScreenBounds
        {
            get { return m_screenBounds; }
        }

        public static Bitmap MakeScreenShot(Rectangle bounds)
        {
            var screenshot = new Bitmap(bounds.Width, bounds.Height, PixelFormat.Format32bppArgb);
            using(var graphics = Graphics.FromImage(screenshot))
            {
                graphics.CopyFromScreen(bounds.Left, bounds.Top, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy);
            }
            return screenshot;
        }
        public static Bitmap MakeScreenShot()
        {
            return MakeScreenShot(ScreenBounds);
        }
    }
}
